package com.opeartion.service.impl;

import com.opeartion.dao.RankMapper;
import com.opeartion.dao.RankPlusMapper;
import com.opeartion.pojo.Category;
import com.opeartion.pojo.ClassesRank;
import com.opeartion.service.RankPlusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author sanshi
 * @version 1.0
 * @data 2020/6/6-20:06
 */

@Service
public class RankPulsServiceImpl implements RankPlusService {
    @Autowired
    private RankPlusMapper rankPlusMapper;
    @Autowired
    private RankMapper rankMapper;

    /**
     * 查询
     *
     * @return
     */
    @Override
    public List<ClassesRank> findRankPlus() {
        return rankPlusMapper.findRankPlus();
    }

    @Override
    public List<ClassesRank> findRankPlus(String name) {
        return rankPlusMapper.findRankPlus(name);
    }

    /**
     * 查询所包含的行业
     */
    @Override
    public List<Category> findCategoryAndClass(int id) {
       return rankMapper.findCategoryAndClass(id);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    public int deleteClass(int id) {
        try {
            rankMapper.deleteCategoryClass(id);
            return rankPlusMapper.deleteClass(id);
        }catch (Exception e) {
            e.printStackTrace();
          return 0;
        }
    }

    /**
     * 修改
     *
     * @param classesRank
     */
    @Override
    public void updateRankPlus(ClassesRank classesRank) {
        Map map = new HashMap();
        map.put("id", classesRank.getId());
        map.put("name", classesRank.getName());
        map.put("rank", classesRank.getRank());
        rankPlusMapper.updateRankPlus(map);
    }



}
